package org.yty.travelagencymongodb.service.impl;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.yty.travelagencymongodb.model.Entity.Order;
import org.yty.travelagencymongodb.repository.OrderRepository;
import org.yty.travelagencymongodb.service.OrderService;

import java.util.Optional;

@Service
@RequiredArgsConstructor
public class OrderServiceImpl implements OrderService {
    private final OrderRepository orderRepository;

    @Override
    public Order getById(Long id) {
        Optional<Order> option = this.orderRepository.findById(id);
        return option.isEmpty() ? null : option.get();
    }

    @Override
    public void removeById(Long id) {
        this.orderRepository.deleteById(id);
    }
}
